package com.doctor.ui.consulting;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.doctor.bean.DoctorBean;
import com.doctor.comm.ConstConfig;
import com.doctor.comm.MyApplication;
import com.doctor.database.DbOperator;
import com.doctor.ui.BaseActivity;
import com.doctor.ui.LoginActivity;
import com.doctor.ui.R;

public class AnswerDoctorPhoneActivity extends BaseActivity{

	/**
	 * 接听医生电话
	 */
	
	private DoctorBean bean;
	private TextView exitBtn,enterBtn;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.answer_phone_doctor_detail);
		
		bean=(DoctorBean) getIntent().getSerializableExtra(ConstConfig.BEAN);
		initiaView();
	}
	
	@Override
	protected void initiaView() {
		// TODO Auto-generated method stub
		TextView name=(TextView) findViewById(R.id.name);
		name.setText(bean.getRealname());
		
		TextView sex=(TextView) findViewById(R.id.sex);
		String sex_txt=bean.getSex();
		if ("男".equals(sex_txt)) {
			sex.setText("男");
		} else if ("女".equals(sex_txt)) {
			sex.setText("女");
		}
		
		TextView hospital=(TextView) findViewById(R.id.hospital);
		hospital.setText(bean.getHospital());
		
		TextView postTitle=(TextView) findViewById(R.id.postTitle);
		postTitle.setText(bean.getZc());
		
		TextView partment=(TextView) findViewById(R.id.partment);
		partment.setText(bean.getKs());
		
		TextView post=(TextView) findViewById(R.id.post);
		post.setText(bean.getZw());
		
		TextView advantage=(TextView) findViewById(R.id.advantage);
		
		String advantage_txt=DbOperator.getInstance(AnswerDoctorPhoneActivity.this).getFieldById(ConstConfig.ADVANTAGE_TABLE, bean.getExpertise(), "_name");
		if (advantage_txt!=null) {
			advantage.setText(advantage_txt);
		}		
		
		TextView diagTime=(TextView) findViewById(R.id.diagTime);
		diagTime.setText(bean.getCztime());
		
		TextView address=(TextView) findViewById(R.id.address);
		address.setText(bean.getAddress());
		
		TextView phone=(TextView) findViewById(R.id.phone);
		phone.setText(bean.getTel());
		
		TextView mobile=(TextView) findViewById(R.id.mobile);
		mobile.setText(bean.getMobile());
		
		TextView specialNum=(TextView) findViewById(R.id.specialNum);
		specialNum.setText(bean.getZh());
		
		TextView email=(TextView) findViewById(R.id.email);
		email.setText(bean.getEmail());
		
		TextView qq=(TextView) findViewById(R.id.qq);
		qq.setText(bean.getQq());
		
		TextView blog=(TextView) findViewById(R.id.blog);
		blog.setText(bean.getBlog());
		
		TextView fetion=(TextView) findViewById(R.id.fetion);
		fetion.setText(bean.getFx());
		
		TextView webChart=(TextView) findViewById(R.id.webChart);
		webChart.setText(bean.getWx());
		
		TextView webSite=(TextView) findViewById(R.id.webSite);
		webSite.setText(bean.getWebsite());
		
		TextView other=(TextView) findViewById(R.id.other);		
		other.setText(bean.getRemark());
		
		TextView birthday=(TextView) findViewById(R.id.birthday);
		birthday.setText(bean.getBrith());
		
		exitBtn=(TextView) findViewById(R.id.exitBtn);
		enterBtn=(TextView) findViewById(R.id.enterBtn);
		if(MyApplication.getInstance().getUserId()>=0){
			//已登录
			exitBtn.setEnabled(false);
			enterBtn.setEnabled(false);
			exitBtn.setVisibility(View.INVISIBLE);
			enterBtn.setVisibility(View.INVISIBLE);
		} else {
			//未登录
			exitBtn.setOnClickListener(click);
			enterBtn.setOnClickListener(click);
		}
		
	}
	
	
	android.view.View.OnClickListener click=new View.OnClickListener() {
		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			if (arg0==exitBtn) {
				finish();
			} else if (arg0==enterBtn) {
				Intent intent=new Intent(AnswerDoctorPhoneActivity.this,LoginActivity.class);
				startActivity(intent);
				finish();
			}
		}
	};
	
	
	
}
